package com.admin.scroller.photoorvideo.holders;

import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.admin.scroller.photoorvideo.PhotoChoseActivity;
import com.admin.scroller.photoorvideo.R;
import com.admin.scroller.photoorvideo.viewModel.PhotoViewModel;

public class TakenPhotosHolder extends RecyclerView.ViewHolder {

    private ImageView imageView;
    private PhotoViewModel viewModel;

    public static TakenPhotosHolder getHolder(Context context, ViewGroup parent, int type){
        View view = LayoutInflater.from(context).inflate(R.layout.layout_photo_item_take,parent,false);
        return new TakenPhotosHolder(view);
    }

    private TakenPhotosHolder(View itemView) {
        super(itemView);
        imageView = itemView.findViewById(R.id.iv_take_photo);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(viewModel==null){
                    viewModel=ViewModelProviders.of(PhotoChoseActivity.activity).get(PhotoViewModel.class);
                }
                viewModel.takenPhoto(1);
            }
        });
    }

}
